#Include Once "Windows.bi"
#Include Once "Crt\String.bi"
#Include Once "htmlayout.bi"



Dim Shared xywh_library_auto_memory As Any Ptr



Function UnicodeToAsci(WStrPtr As WString Ptr,WStrLen As UInteger) As Any Ptr
	If WStrLen = 0 Then
		WStrLen = wcslen(WStrPtr)
	EndIf
	Dim ZStrLen As Integer = WideCharToMultiByte(CP_ACP,0,WStrPtr,WStrLen,NULL,0,NULL,NULL)
	Dim ZStrMem As ZString Ptr = Allocate(ZStrLen+1)
	WideCharToMultiByte(CP_ACP,0,WStrPtr,WStrLen,ZStrMem,ZStrLen,NULL,NULL)
	ZStrMem[ZStrLen] = 0
	Return ZStrMem
End Function

Function AsciToUnicode(ZStrPtr As ZString Ptr,ZStrLen As UInteger) As Any Ptr
	If ZStrLen = 0 Then
		ZStrLen = strlen(ZStrPtr)
	EndIf
	Dim WStrLen As Integer = MultiByteToWideChar(CP_ACP,0,ZStrPtr,ZStrLen,NULL,0)
	Dim WStrMem As WString Ptr = Allocate(WStrLen*SizeOf(WString)+2)
	MultiByteToWideChar(CP_ACP,0,ZStrPtr,ZStrLen,WStrMem,WStrLen)
	WStrMem[WStrLen] = 0
	Return WStrMem
End Function

Function W2A(UStr As WString Ptr,ULen As UInteger=0) As ZString Ptr
	DeAllocate(xywh_library_auto_memory)
	xywh_library_auto_memory = UnicodeToAsci(UStr,ULen)
	Return xywh_library_auto_memory
End Function

Function A2W(AStr As ZString Ptr,ALen As UInteger=0) As WString Ptr
	DeAllocate(xywh_library_auto_memory)
	xywh_library_auto_memory = AsciToUnicode(AStr,ALen)
	Return xywh_library_auto_memory
End Function



Function DlgProc(ByVal hWin As HWND, ByVal uMsg As UINT, ByVal wParam As WPARAM, ByVal lParam As LPARAM) As Integer
	Dim As Integer lResult, bHandled, id, Event
	lResult = HTMLayoutProcND(hWin, uMsg, wParam, lParam, @bHandled)
	If bHandled Then Return lResult
	Select Case uMsg
		Case WM_INITDIALOG
			HTMLayoutLoadFile(hWin, A2W(ExePath & "\index.htm"))
		Case WM_COMMAND
			
		Case WM_CLOSE
			EndDialog(hWin, 0)
		Case Else
			Return FALSE
	End Select
	Return TRUE
End Function



DialogBoxParam(GetModuleHandle(NULL),Cast(zstring ptr,1000),NULL,@DlgProc,0)
ExitProcess(0)